package com.neusoft.controller;

import com.neusoft.domain.Business;
import com.neusoft.domain.PageResult;
import com.neusoft.domain.Result;
import com.neusoft.service.BusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/business")
public class BusinessController {
    @Autowired
    private BusinessService businessService;
    @GetMapping("/pageSelectBusiness")
    public Result pageSelectBusiness(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize") Integer pageSize,@RequestParam("account") String account,@RequestParam("telephone") String telephone){
        PageResult<Business>result=businessService.pageSelectBusiness(pageNum,pageSize,account,telephone);
        return  Result.success(result);
    }
    @PostMapping("/updateBusiness")
    public Result updateBusiness(@RequestBody Business business){
        businessService.updateBusiness(business);
        return Result.success();
    }
    @PutMapping("/deleteBusiness/{id}")
    public Result deleteBusiness(@PathVariable("id") Integer id){
        businessService.deleteBusiness(id);
        return Result.success();
    }
    @PostMapping("/addBusiness")
    public Result addBusiness(@RequestBody Business business){
        businessService.addBusiness(business);
        return Result.success();
    }
}
